package com.example.pertecttime.fragent.timeline;


import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.StaggeredGridLayoutManager;

import com.example.pertecttime.R;
import com.example.pertecttime.adapter.MyAdapter;
import com.example.pertecttime.base.BaseFragment;

import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;

/**
 * Created by 半生瓜 on 2017/7/21.
 */

public class TimelineFragment extends BaseFragment<TimelinePresent, TimelineModel> implements TimelineContract.View {
    private RecyclerView recyclerView;
    private LinkedList<Map<String, Object>> products = new LinkedList<Map<String, Object>>();
    private String content = "哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈";

    @Override
    public int getLayoutId() {
        return R.layout.timeline_layout;
    }

    @Override
    public void initView() {
        initVar();
        recyclerView = (RecyclerView) getActivity().findViewById(R.id.recyclerView);
        recyclerView.setLayoutManager(new StaggeredGridLayoutManager(2
                , StaggeredGridLayoutManager.VERTICAL));
        MyAdapter adapter = new MyAdapter(products);
        recyclerView.setAdapter(adapter);

    }

    private void initVar() {
        for (int i = 0; i < 20; i++) {
            Map<String, Object> listItem = new HashMap<String, Object>();
            if (i % 2 == 0) {
                listItem.put("title", "title" + i);
                listItem.put("content", content + i);
                listItem.put("face", R.drawable.lg_logo);
            } else {
                listItem.put("title", "title " + i);
                listItem.put("content", "content" + i);
                listItem.put("face", R.drawable.drawlayout_haer);
            }

            products.add(listItem);
        }
    }

    @Override
    public void initclicklisten() {

    }


    @Override
    public void onresult(String a) {

    }
}